/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Form_Utama.java
 *
 * Created on Nov 15, 2011, 9:16:24 PM
 */
package Boundaries;

import Controller.Add_Controller;
import Controller.Registration_Controller;
import Controller.Servis_Controller;
import Entities.Karyawan;
import Entities.Kendaraan;
import Entities.Servis;
import TableModel.Kendaraan_List;
import TableModel.Kendaraan_TableModel;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author Adrian
 */
public class Form_Utama extends javax.swing.JFrame {

    /** Creates new form Form_Utama */
    /*
     * pemebuat object internal frame
     */
    InternalFrame_Kendaraan internalFrame_Kendaraan = new InternalFrame_Kendaraan();
    InternalFrame_Persewaan internalFrame_Persewaan = new InternalFrame_Persewaan(null);
    InternalFrame_Rekap internalFrame_Rekap = new InternalFrame_Rekap(null);
    InternalFrame_Servis internalFrame_Servis = new InternalFrame_Servis();
    InternalFrame_ubahStatusStaff internalFrame_ubahStatusStaff = new InternalFrame_ubahStatusStaff();
    InternalFrame_ubahStatusAdmin internalFrame_ubahStatusAdmin = new InternalFrame_ubahStatusAdmin();
    String username;

    public Form_Utama(Karyawan karywan) {
        Karyawan karyawan = karywan;

        try {
            initComponents();
            if (Login_Form.Akses().matches("ADMIN")) {
                panel_Staff.setVisible(false);
                panel_Admin.setVisible(true);
                username = karyawan.getUsername();

            } else if (Login_Form.Akses().matches("STAFF")) {
                panel_Staff.setVisible(true);
                System.out.println("Masuk lagiii");
                internalFrame_Persewaan.label_Sewa_username.setText(karyawan.getUsername());
                username = karyawan.getUsername();
                panel_Admin.setVisible(false);
            } else {
                panel_Staff.setVisible(false);
                panel_Admin.setVisible(false);
            }

        } catch (Exception ex) {
            Logger.getLogger(Form_Utama.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panel_header = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        label_SPPK = new javax.swing.JLabel();
        label_RentalMobil1Milyar = new javax.swing.JLabel();
        panel_Admin = new javax.swing.JPanel();
        button_AdminKendaraan = new javax.swing.JButton();
        button_UbahStatus = new javax.swing.JButton();
        button_AdminRekap = new javax.swing.JButton();
        label_Admin = new javax.swing.JLabel();
        button_AdminServis = new javax.swing.JButton();
        button_LogoutAdmin = new javax.swing.JButton();
        panel_Staff = new javax.swing.JPanel();
        label_Staff = new javax.swing.JLabel();
        button_StaffSewa = new javax.swing.JButton();
        button_StaffKendaraan = new javax.swing.JButton();
        button_LogoutStaff = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("SPPK Rental Mobil 1 Milyar");
        setResizable(false);

        panel_header.setBackground(new java.awt.Color(255, 255, 255));
        panel_header.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        panel_header.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Boundaries/Untitled-1.jpg"))); // NOI18N
        panel_header.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 110, 70));

        label_SPPK.setFont(new java.awt.Font("Tahoma", 2, 11));
        label_SPPK.setText("Sistem Pembantu Persewaan Kendaraan");
        panel_header.add(label_SPPK, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 10, -1, -1));

        label_RentalMobil1Milyar.setFont(new java.awt.Font("Trebuchet MS", 1, 36));
        label_RentalMobil1Milyar.setText("RENTAL MOBIL 1 MILYAR");
        panel_header.add(label_RentalMobil1Milyar, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 20, -1, -1));

        panel_Admin.setBackground(new java.awt.Color(255, 255, 255));
        panel_Admin.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        panel_Admin.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        button_AdminKendaraan.setText("Tambah Kendaraan");
        button_AdminKendaraan.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        button_AdminKendaraan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_AdminKendaraanActionPerformed(evt);
            }
        });
        panel_Admin.add(button_AdminKendaraan, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 90, 130, 49));

        button_UbahStatus.setText(" Kembali Sevis");
        button_UbahStatus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_UbahStatusActionPerformed(evt);
            }
        });
        panel_Admin.add(button_UbahStatus, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 150, 130, 49));

        button_AdminRekap.setText("Rekap");
        button_AdminRekap.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_AdminRekapActionPerformed(evt);
            }
        });
        panel_Admin.add(button_AdminRekap, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 270, 130, 49));
        button_AdminRekap.getAccessibleContext().setAccessibleDescription("");

        label_Admin.setFont(new java.awt.Font("Tahoma", 1, 14));
        label_Admin.setText("A D M I N");
        panel_Admin.add(label_Admin, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 20, -1, -1));

        button_AdminServis.setText("Servis");
        button_AdminServis.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_AdminServisActionPerformed(evt);
            }
        });
        panel_Admin.add(button_AdminServis, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 210, 130, 49));

        button_LogoutAdmin.setText("Logout");
        button_LogoutAdmin.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        button_LogoutAdmin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_LogoutAdminActionPerformed(evt);
            }
        });
        panel_Admin.add(button_LogoutAdmin, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 440, -1, -1));

        panel_Staff.setBackground(new java.awt.Color(255, 255, 255));
        panel_Staff.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        panel_Staff.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        label_Staff.setFont(new java.awt.Font("Tahoma", 1, 14));
        label_Staff.setText("S T A F F");
        panel_Staff.add(label_Staff, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 10, -1, -1));

        button_StaffSewa.setText("Sewa");
        button_StaffSewa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_StaffSewaActionPerformed(evt);
            }
        });
        panel_Staff.add(button_StaffSewa, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 90, 130, 49));

        button_StaffKendaraan.setText("Ubah Status");
        button_StaffKendaraan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_StaffKendaraanActionPerformed(evt);
            }
        });
        panel_Staff.add(button_StaffKendaraan, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 150, 130, 49));

        button_LogoutStaff.setText("Logout");
        button_LogoutStaff.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        button_LogoutStaff.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_LogoutStaffActionPerformed(evt);
            }
        });
        panel_Staff.add(button_LogoutStaff, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 430, -1, -1));

        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1008, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 478, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(panel_header, javax.swing.GroupLayout.PREFERRED_SIZE, 1160, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(panel_Staff, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(panel_Admin, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(panel_header, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(panel_Staff, javax.swing.GroupLayout.PREFERRED_SIZE, 480, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(panel_Admin, javax.swing.GroupLayout.PREFERRED_SIZE, 480, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-1168)/2, (screenSize.height-600)/2, 1168, 600);
    }// </editor-fold>//GEN-END:initComponents

    private void button_AdminKendaraanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_AdminKendaraanActionPerformed
        // TODO add your handling code here:
        internalFrame_Kendaraan.setVisible(false);
        internalFrame_Kendaraan = new InternalFrame_Kendaraan();
        jPanel1.add(internalFrame_Kendaraan);
        internalFrame_Kendaraan.setVisible(true);
        internalFrame_Rekap.setVisible(false);
        internalFrame_Servis.setVisible(false);
        internalFrame_ubahStatusAdmin.setVisible(false);

    }//GEN-LAST:event_button_AdminKendaraanActionPerformed

    private void button_AdminRekapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_AdminRekapActionPerformed
        // TODO add your handling code here:
        internalFrame_Rekap.setVisible(false);
        internalFrame_Rekap = new InternalFrame_Rekap(username);
        jPanel1.add(internalFrame_Rekap);
        internalFrame_Kendaraan.setVisible(false);
        internalFrame_Rekap.setVisible(true);
        internalFrame_Servis.setVisible(false);
        internalFrame_ubahStatusAdmin.setVisible(false);

    }//GEN-LAST:event_button_AdminRekapActionPerformed

    private void button_UbahStatusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_UbahStatusActionPerformed
        // TODO add your handling code here:
        internalFrame_ubahStatusAdmin.setVisible(false);
        internalFrame_ubahStatusAdmin = new InternalFrame_ubahStatusAdmin();
        jPanel1.add(internalFrame_ubahStatusAdmin);
        internalFrame_Kendaraan.setVisible(false);
        internalFrame_Rekap.setVisible(false);
        internalFrame_Servis.setVisible(false);
        internalFrame_ubahStatusAdmin.setVisible(true);
    }//GEN-LAST:event_button_UbahStatusActionPerformed

    private void button_StaffSewaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_StaffSewaActionPerformed
        // TODO add your handling code here:
        internalFrame_Persewaan.setVisible(false);
        internalFrame_Persewaan = new InternalFrame_Persewaan(username);
        jPanel1.add(internalFrame_Persewaan);
        //jPanel1.add(internalFrame_Persewaan.jInternalFrame1);
        internalFrame_ubahStatusStaff.setVisible(false);
        internalFrame_Persewaan.setVisible(true);
    }//GEN-LAST:event_button_StaffSewaActionPerformed

    private void button_StaffKendaraanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_StaffKendaraanActionPerformed
        // TODO add your handling code here:
        internalFrame_ubahStatusStaff.setVisible(false);
        internalFrame_ubahStatusStaff = new InternalFrame_ubahStatusStaff();
        jPanel1.add(internalFrame_ubahStatusStaff);
        internalFrame_ubahStatusStaff.setVisible(true);
        internalFrame_Persewaan.setVisible(false);
    }//GEN-LAST:event_button_StaffKendaraanActionPerformed

    private void button_AdminServisActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_AdminServisActionPerformed
        // TODO add your handling code here:
        internalFrame_Servis.setVisible(false);
        internalFrame_Servis = new InternalFrame_Servis();
        jPanel1.add(internalFrame_Servis);
        internalFrame_Kendaraan.setVisible(false);
        internalFrame_Rekap.setVisible(false);
        internalFrame_Servis.setVisible(true);
        internalFrame_ubahStatusAdmin.setVisible(false);
    }//GEN-LAST:event_button_AdminServisActionPerformed

    private void button_LogoutAdminActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_LogoutAdminActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
        Login_Form login_Form = new Login_Form();
        login_Form.setVisible(true);
    }//GEN-LAST:event_button_LogoutAdminActionPerformed

    private void button_LogoutStaffActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_LogoutStaffActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
        Login_Form login_Form = new Login_Form();
        login_Form.setVisible(true);
    }//GEN-LAST:event_button_LogoutStaffActionPerformed
    /**
     * @param args the command line arguments
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton button_AdminKendaraan;
    private javax.swing.JButton button_AdminRekap;
    private javax.swing.JButton button_AdminServis;
    private javax.swing.JButton button_LogoutAdmin;
    private javax.swing.JButton button_LogoutStaff;
    private javax.swing.JButton button_StaffKendaraan;
    private javax.swing.JButton button_StaffSewa;
    private javax.swing.JButton button_UbahStatus;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel label_Admin;
    private javax.swing.JLabel label_RentalMobil1Milyar;
    private javax.swing.JLabel label_SPPK;
    private javax.swing.JLabel label_Staff;
    private javax.swing.JPanel panel_Admin;
    private javax.swing.JPanel panel_Staff;
    private javax.swing.JPanel panel_header;
    // End of variables declaration//GEN-END:variables
}
